﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Manager_AddCandidate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            //get value from form creat candidate
            string Username = txtUsername.Text;
            string Password = txtPassword.Text;
            string Email = txtEmail.Text;
            string Fullname = txtFullname.Text;
            string Mobile = txtMobile.Text;
            string Certificate = txtCertificate.Text;
            string Experience = txtExperience.Text;
            string Address = txtAddress.Text;

            Candidate candidate = new Candidate();
            candidate.Username = Username;
            candidate.Password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Password, "MD5");
            candidate.Email = Email;
            candidate.Fullname = Fullname;
            candidate.Address = Address;
            candidate.Certificate = Certificate;
            candidate.Experience = Experience;
            candidate.Mobile = Mobile;
            
            RegisterCandidate reg = new RegisterCandidate();

            if (reg.Register(candidate))
                Session.Add("Message", "Register candidate successfully");
            else
                Session.Add("Message", "<font color='red'>Error : Register candidate unsuccess</font>");

            Response.Redirect("CandidateManager.aspx");
        }
    }
}